#pragma once

#include <math.h>
#include <time.h>
#include <fstream>
#include "FreeImage/FreeImage.h"
#include "util_math.h"
#include "Scene.h"
#include "DirectionalLight.h"
#include "LinearCellScene.h"
#include "QuadTreeCellScene.h"
#include "KdTreeCellScene.h"
#include "TriCell.h"
#include "Viewerf.h"
#include "Vector3f.h"
#include "monoSample.h"
#include "monoSampleSlopeColumn.h"

using namespace std;

class User {
private:
    clock_t readyClock;
    clock_t frameClock;
    int frameCount;

    float viewRotateLeft, viewRotateUp, lightRotateLeft, lightRotateUp;
    float viewMove;

    float viewRotateSpeed, lightRotateSpeed;
    float viewMoveSpeed;

    float mouseSensitivity;
    int lastMouseX, lastMouseY;
    int diffMouseX, diffMouseY;

    int mouseButton;
public:
    ofstream logfile;
    Viewerf viewer;
    Scene* scene;
    bool useColumnTracing;

    //default log file
    User();

    void setViewsize(int x, int y);

    //config file operations
    void useConfigFile(const char* filename);

    void op_fov(ifstream& configfile);
    void op_viewer_pos(ifstream& configfile);
    void op_viewer_dir(ifstream& configfile);
    void op_viewsize(ifstream& configfile);
    void op_heightmap(ifstream& configfile);
    void op_userLight(ifstream& configfile);
    void op_columnTracing(ifstream& configfile);
    void op_viewMoveSpeed(ifstream& configfile);
    void op_mouseSensitivity(ifstream& configfile);

    void ready();
    void render();
    void reshape(int w, int h);
    void idle();
    void processNormalKeys(unsigned char key, int x, int y);
    void keyboardUp(unsigned char key, int x, int y);
    void mouseState(int button, int state, int x, int y);
    void mouseMotion(int x, int y);
    void quit();
};
